import {request} from '@/plugins/axios'
import {getRoleNames, getPlatformId} from "@/utils/session_storage"
import ApiPath from '@/utils/api_paths'

export function getMenus() {
    return request({
        url: ApiPath.menu.getMenus,
        method: 'post',
        data: {'roleNames': getRoleNames(), 'platformId': getPlatformId()}
    })
}

export function list(query) {
    return request({
        url: ApiPath.menu.list,
        method: 'get',
        params: query
    })
}

export function listAll() {
    return request({
        url: ApiPath.menu.listAll,
        method: 'get'
    })
}

export function add(data) {
    return request({
        url: ApiPath.menu.add,
        method: 'post',
        data
    })
}

export function del(id) {
    return request({
        url: ApiPath.menu.del + '/' + id,
        method: 'delete'
    })
}

export function update(data) {
    return request({
        url: ApiPath.menu.update + '/' + data.menuId,
        method: 'put',
        data
    })
}

export function get(id) {
    return request({
        url: ApiPath.menu.get + '/' + id,
        method: 'get'
    })
}
